//
//  ByDayEarningPointSwitch.m
//  mijifen_ios
//
//  Created by mc on 2017/10/30.
//  Copyright © 2017年 itboye. All rights reserved.
//

#import "ByDayEarningPointSwitch.h"
// view
#import "ByViewHeaderSuccess.h"

@interface ByDayEarningPointSwitch ()

@end

@implementation ByDayEarningPointSwitch

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"积分转换";
    [self addLeftBackBarButtonItem];
    self.view.backgroundColor = BY_TABLE_COLOR;
    [self createViews];
}

#pragma mark - 创建成功
- (void)createViews{
    ByViewHeaderSuccess *headerView = [[ByViewHeaderSuccess alloc] initWith:@"DayEarning_switch_success" title:@"转换成功"];
    [self.view addSubview:headerView];
    __block CGFloat height;
    [headerView mas_makeConstraints:^(MASConstraintMaker *make) {
        if (@available(iOS 11.0,*)) {
            height = (self.view.height - 50 * 2 - 10 - self.view.safeAreaInsets.bottom) / 2;
            make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop);
            make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, height));
        }else{
            height = (self.view.height - 50 * 2 - 10) / 2;
            make.top.equalTo(self.view.mas_top);
            make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, height));
        }
        
    }];
    UIView *infoBgView = [[UIView alloc] init];
    [self.view addSubview:infoBgView];
    [infoBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(headerView.mas_bottom).offset(20);
        make.left.equalTo(headerView.mas_left);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, 140));
    }];
    infoBgView.backgroundColor = [UIColor whiteColor];
    // 积分
    NSString *pointStr = [NSString stringWithFormat:@"- %@",self.point];
    CGFloat width = [pointStr getSizeOfString:30].width + 15;
    UILabel *pointLabel = [[UILabel alloc] init];
    [infoBgView addSubview:pointLabel];
    [pointLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(infoBgView.mas_top).offset(20);
        make.left.equalTo(infoBgView.mas_left).offset((SCREEN_WIDTH - 30 - width)/ 2);
        make.size.mas_equalTo(CGSizeMake(width, 30));
    }];
    pointLabel.text = pointStr;
    pointLabel.font = FONT(30);
    pointLabel.textColor = [UIColor colorWithR:34 g:150 b:217];
    
    UIImageView *pointImg = [[UIImageView alloc] init];
    [infoBgView addSubview:pointImg];
    [pointImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(pointLabel.mas_right);
        make.top.equalTo(pointLabel.mas_top);
        make.size.mas_equalTo(CGSizeMake(30, 30));
    }];
    pointImg.image = [UIImage imageNamed:@"Message_point"];
    
    UIView *lineView2 = [[UIView alloc] init];
    [infoBgView addSubview:lineView2];
    [lineView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(infoBgView.mas_left);
        make.top.equalTo(pointLabel.mas_bottom).offset(20);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, 1));
    }];
    lineView2.backgroundColor = [UIColor lightGrayColor];
   
    UILabel *priceLabel = [[UILabel alloc] init];
    [infoBgView addSubview:priceLabel];
    [priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(lineView2.mas_bottom).offset(20);
        make.left.equalTo(infoBgView.mas_left);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, 30));
    }];
    priceLabel.font = FONT(30);
    priceLabel.textAlignment = NSTextAlignmentCenter;
    priceLabel.text = [NSString stringWithFormat:@"+ ¥%@",self.point];
    priceLabel.textColor = [UIColor redColor];
    
    
    // 金额
    
    UIButton *backButton = [[UIButton alloc] init];
    [self.view addSubview:backButton];
    [backButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left);
        if (@available(iOS 11.0,*)) {
            make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
        }else{
            make.bottom.equalTo(self.view.mas_bottom);
        }
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, 50));
    }];
    [backButton setTitle:@"返回" forState:UIControlStateNormal];
    [backButton setTitleColor:BY_TEXT_COLOR forState:UIControlStateNormal];
    [backButton setBackgroundColor:BY_THEME_COLOR];
    [backButton addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
    
}

- (void)backAction{
    [self dismissViewControllerAnimated:YES completion:nil];
}


@end
